package org.thinker.sp1;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;

@Controller
@RequestMapping("/simple")
public class SimpleController {

	static Logger logger = Logger.getLogger(SimpleController.class);
	
	@RequestMapping(value="/")
	public void simpleCall(){
		logger.info("simpleCall....");
	}
	
	@RequestMapping(value="/",method={RequestMethod.POST} )
	public String simpleCall2(){
		logger.info("simpleCall2....");
		return "simplePost";
	}
	
	
	@RequestMapping(value="/param")
	public void simpleParam(@RequestParam("userid") String userId){
		
		logger.info("simple param:" + userId);
		 
	}
	
	@RequestMapping(value="/param2")
	public void simpleParam(String p1, String p2){
		
		logger.info("simple param p1:" + p1);
		logger.info("simple param p2:" + p2);
		 
	}	

	@RequestMapping(value="/path/{seqno}")
	public void simplePath(@PathVariable("seqno") String seqno){
		
		logger.info("simple path seqno:" + seqno);
		
		 
	}	

	@RequestMapping(value="/path/{seqno}/{job}")
	public void simplePath2(@PathVariable("seqno") String seqno, @PathVariable("job") String job){
		
		logger.info("simple path seqno:" + seqno);
		logger.info("simple path job:" + job);
	}

	@RequestMapping(value="/browser")
	public void simpleHeader(@RequestHeader("user-Agent")String userAgent){
		
		logger.info("simpleHeader : "+ userAgent);
	}
	
	@RequestMapping(value="/body", method={RequestMethod.POST})
	public void simpleBody(@RequestBody String request){
		
		logger.info("simpleBody : "+ request);
	}	
	
	@RequestMapping(value="/findCookie")
	public void simpleCookie(String param, @CookieValue(defaultValue="NONE") String ord){
		
		
		logger.info("simpleCookie : "+ ord);
		logger.info("param: " + param);
	}
	
}



